package edu.put.sk.nrpp.ui;


import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;

import edu.put.sk.nrpp.ConnectionList;
import edu.put.sk.nrpp.ObserverNetwork;
import edu.put.sk.nrpp.Router;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.Hashtable;

import javax.swing.JScrollPane;

public class ExampleWindow implements ObserverNetwork {
	private JFrame frame;

	/**
	 * Create the application.
	 */
	public ExampleWindow() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	GraphicsPanel examplePanel;
	JScrollPane scrollpane;
	private void initialize() {
		setFrame(new JFrame());
		getFrame().setBounds(100, 100, 700, 700);
		getFrame().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(new BorderLayout(0, 0));
		examplePanel = new GraphicsPanel();
		examplePanel.setPreferredSize(new java.awt.Dimension(examplePanel.maxX, examplePanel.maxY));
		scrollpane = new JScrollPane(examplePanel);
	    frame.add(scrollpane, BorderLayout.CENTER);
		
		JMenuBar menuBar = new JMenuBar();
		getFrame().setJMenuBar(menuBar);
		
		JMenu mnFile = new JMenu("File");
		menuBar.add(mnFile);
		
		JMenuItem mntmFile = new JMenuItem("NoThing");
		mntmFile.setSelected(true);
		mnFile.add(mntmFile);
		
		JMenuItem mntmAbout = new JMenuItem("Exit");
		mntmAbout.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				System.exit(0);
			}
		});
		mnFile.add(mntmAbout);
		
	}

	/**
	 * @param frame the frame to set
	 */
	public void setFrame(JFrame frame) {
		this.frame = frame;
	}

	/**
	 * @return the frame
	 */
	public JFrame getFrame() {
		return frame;
	}

	@Override
	public void update(Hashtable<String, Router> dictionary) {
		// TODO Auto-generated method stub
		System.out.println("Otrzymane dane o ruterach: ");
		for (Router rou:dictionary.values()){
			System.out.println(dictionary.get(rou));
		}

	}
}
